import 'package:bloc/bloc.dart';

///
/// 视频中对话bloc
/// 
class LiveEmojiBloc extends Bloc<LiveEmojiEvent, bool> {
  bool show = false;

  @override
  bool get initialState => false;

  @override
  Stream<bool> mapEventToState(LiveEmojiEvent event) async* {
    // 切换emoji
    if (event is LiveEmojiToggle) {
      yield* _mapToggleToState(event);
    }
    // 隐藏emoji
    else if (event is LiveEmojiHide) {
      yield* _mapHideToState(event);
    }
  }

  // 切换emoji
  Stream<bool> _mapToggleToState(LiveEmojiToggle event) async* {
    show = !show;
    yield show;
  }

  // 隐藏emoji
  Stream<bool> _mapHideToState(LiveEmojiHide event) async* {
    show = false;
    yield false;
  }

}

// 事件抽象
abstract class LiveEmojiEvent {
  const LiveEmojiEvent();
}

// 事件：切换emoji
class LiveEmojiToggle extends LiveEmojiEvent {
  const LiveEmojiToggle();
}

// 事件：隐藏emoji
class LiveEmojiHide extends LiveEmojiEvent {
  const LiveEmojiHide();
}
